<?php 
/**
 * Convertion de données
 *
 * @package zfbook
 * @subpackage convert
 */
abstract class Zfbook_Convert
{
    const CSV = 'csv';

    /**
     * Retourne l'instance d'une classe de conversion
     *
     * @throws Zfbook_Convert_Exception
     * @return Zfbook_Convert_Interface
     */
    public static function getConverter($converter)
    {
        $class = 'Zfbook_Convert_' . ucfirst(strtolower($converter));
        if (!class_exists($class, false)) {
            throw new Zfbook_Convert_Exception("Class $class not found");
        } else {
            $reflexionClass = new ReflectionClass($class);
            if (!$reflexionClass->implementsInterface('Zfbook_Convert_Interface')) {
                $msg = "Class $class doesn not implement Zfbook_Convert_Interface";
                throw new Zfbook_Convert_Exception($msg);
            }
        }
        return call_user_func(array($class, 'getInstance'));
    }
}
